package com.test.proxy_pattern.moveproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class ProxyFactory {


    private Object object;

    public ProxyFactory(Object object) {
        this.object = object;
    }

    public Object getProxyRunFactory( ){

        Object o = Proxy.newProxyInstance(object.getClass().getClassLoader(), object.getClass().getInterfaces(), new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

                System.out.println("开始计时！！！！！！");

                Object invokes = method.invoke(object, args);

                System.out.println("结束计时！！！！！！");
                return invokes;
            }
        });

        return o;
    }




}
